def eliminateDuplicates(numbers): # DO NOT modify this line 
    # TODO: add your code here
    l=len(numbers)
    i=0
    new=[]
    while i<l:
        new.append(numbers[i])
        i+=1
    i=l-1
    while i>=0:
        j=0
        while j<i:
            if new[j]==new[i]:
                del new[i]
                break
            j+=1
        i-=1
    return new# You can modify or delete this line

# === DO NOT modify the code below ===
def main():
    list1 = [ eval(x) for x in input().split() ]
    list2 = eliminateDuplicates(list1)
    print(" ".join(map(str,list1)))
    print(" ".join(map(str,list2)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===